package org.cybzacg.convert.constants;

import java.time.*;
import java.util.Date;
import java.util.Set;

/**
 * 默认日期格式
 */
public final class DateFormats {
    private DateFormats() {
        throw new IllegalStateException("Cannot instantiate DateFormats");
    }

    public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
    public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
    public static final String ISO_DATE = "yyyy-MM-dd'T'HH:mm:ss";
    public static final String ISO_DATE_WITH_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS";
    public static final String SLASH_DATE_FORMAT = "yyyy/MM/dd HH:mm:ss";
    public static final String SLASH_DATE_ONLY = "yyyy/MM/dd";
    public static final String COMPACT_DATE = "yyyyMMdd";
    public static final String COMPACT_DATETIME = "yyyyMMddHHmmss";
    public static final String TIME_ONLY = "HH:mm";
    public static final String TIME_WITH_SECONDS = "HHmmss";
    public static final String TIME_WITH_MILLIS = "HH:mm:ss.SSS";
    public static final String TIMEZONE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
    public static final String TIMEZONE_FORMAT_WITH_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
    public static final String TIMEZONE_ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ssXXX";
    public static final String TIMEZONE_ISO_WITH_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";

    /**
     * 日期时间格式数组
     */
    public static final String[] DATE_FORMAT_PATTERNS = {
            DateFormats.DEFAULT_DATETIME_FORMAT,
            DateFormats.DEFAULT_DATE_FORMAT,
            DateFormats.DEFAULT_TIME_FORMAT,
            DateFormats.ISO_DATE,
            DateFormats.ISO_DATE_WITH_MILLIS,
            DateFormats.SLASH_DATE_FORMAT,
            DateFormats.SLASH_DATE_ONLY,
            DateFormats.COMPACT_DATE
    };

    public static final String[] DATETIME_FORMAT_PATTERNS = {
            DateFormats.DEFAULT_DATETIME_FORMAT,
            DateFormats.ISO_DATE,
            DateFormats.ISO_DATE_WITH_MILLIS,
            DateFormats.SLASH_DATE_FORMAT,
            DateFormats.COMPACT_DATETIME
    };

    public static final String[] TIME_FORMAT_PATTERNS = {
            DateFormats.DEFAULT_TIME_FORMAT,
            DateFormats.TIME_ONLY,
            DateFormats.TIME_WITH_SECONDS,
            DateFormats.TIME_WITH_MILLIS
    };

    public static final String[] TIMEZONE_FORMAT_PATTERNS = {
            DateFormats.DEFAULT_DATETIME_FORMAT,
            DateFormats.TIMEZONE_FORMAT,
            DateFormats.TIMEZONE_FORMAT_WITH_MILLIS,
            DateFormats.TIMEZONE_ISO_FORMAT,
            DateFormats.TIMEZONE_ISO_WITH_MILLIS
    };

    /**
     * 支持的日期时间类型集合
     */
    public static final Set<Class<?>> SUPPORTED_DATETIME_TYPES = Set.of(
            Date.class,
            LocalDate.class,
            LocalDateTime.class,
            LocalTime.class,
            ZonedDateTime.class,
            Instant.class,
            Year.class,
            YearMonth.class,
            Period.class,
            Duration.class
    );
}
